<style scoped>
    .number-modifier {
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>

<style>

</style>

<template>
    <v-coreLayout ref="coreLayout" :step="2" :countdownTime="240">
        <template slot="content">
            <v-exception ref="exceptionModel"></v-exception>
            <Row style="height:80%;">
                <Col span="14">
                    <Row style="margin: 20px;">
                        <Col span="24">
                            <div style="height:100%;display:flex;flex-direction:column;justify-content: center;align-items: center;min-height: 400px;">

                                <div class="pdf-container">
                                    <canvas id="canvas"></canvas>
                                </div>

                                <Page :total="filePageSize" :page-size="1" :current.sync="nowPage" prev-text="Previous" next-text="Next"
                                      @on-change="selectPage"/>
                                <Spin fix v-if="multiPagePreviewRefresh" v-on:click.native="splicingPage()">
                                    <Icon type="md-refresh-circle" size=48></Icon>
                                    <br/>
                                    <div style="font-size: 16px">当你设置完成<br/>请点击此处刷新多页预览</div>
                                </Spin>
                                <Spin fix v-if="multiPagePreviewRefreshLoading">
                                    <Icon type="ios-loading" size=48 class="spin-icon-load"></Icon>
                                    <br/>
                                    <div style="font-size: 16px">正在生成一张多页文件(首次加载可能较为缓慢，请稍后……)</div>
                                </Spin>
                            </div>
                        </Col>
                    </Row>
                    <Row>
                        <Col span="24">
                            <div style="height:100%;display:flex;flex-direction:column;justify-content: center;align-items: center">
                                <Card title="打印机选项" icon="ios-options" :padding="0" shadow
                                      style="width: 65%; margin: 10px">
                                    <CellGroup style="margin-top: 10px;margin-bottom: 10px;">
                                        <Cell title="打印份数" label="Copies">
                                            <div class="number-modifier" slot="extra">
                                                <Button icon="md-add" type="primary" shape="circle" size="small"
                                                        v-on:click="setCopies('add')"></Button>
                                                <Input v-model="copies" readonly
                                                       style="width: 40px; margin-right: 10px;margin-left:10px;"/>
                                                <Button icon="md-remove" type="primary" shape="circle" size="small"
                                                        v-on:click="setCopies('remove')"></Button>
                                            </div>
                                        </Cell>
                                        <Cell title="逐份打印" label="Collate">
                                            <Switch v-model="collate" size="large" slot="extra">
                                                <span slot="open">ON</span>
                                                <span slot="close">OFF</span>
                                            </Switch>
                                        </Cell>
                                    </CellGroup>
                                </Card>
                                <Button @click="setAutoAdjustment" type="success" size="large" icon="md-print"
                                        style="width: 340px;margin-top: 20px;height: 45px;">
                                    <p style="font-size: 18px;">提交打印作业 / Confirm Print Setting</p>
                                </Button>
                            </div>
                        </Col>
                    </Row>
                </Col>

                <Col span="10"
                     style="display:flex;flex-direction:column;justify-content: center;align-items: center">
                    <Card title="高级 - 页面内容和范围选择" icon="ios-options" :padding="0" shadow
                          style="width: 90%; margin: 10px;">
                        <CellGroup style="margin-top: 10px;margin-bottom: 10px;">
                            <Cell title="打印范围" label="Page Range">
                                <RadioGroup v-model="pageRange" type="button" slot="extra">
                                    <Radio label="AllPage">所有页面</Radio>
                                    <Radio label="CurrentPage">当前页面</Radio>
                                    <Radio label="SelectPage">页面选择</Radio>
                                </RadioGroup>
                            </Cell>
                            <Cell title="页面选择" label="Page Selection">
                                <div class="number-modifier" slot="extra">
                                    <Button icon="md-add" type="primary" shape="circle" size="small"
                                            :disabled="pageRange!='SelectPage'"
                                            v-on:click="setStartPage('add')"></Button>
                                    <Input v-model="startPage" readonly slot="extra" :disabled="pageRange!='SelectPage'"
                                           style="width: 40px; margin-right: 10px;margin-left:10px;"/>
                                    <Button icon="md-remove" type="primary" shape="circle" size="small"
                                            :disabled="pageRange!='SelectPage'"
                                            v-on:click="setStartPage('remove')"></Button>
                                    <span style="margin-left:5px;margin-right:5px;"> ~ </span>
                                    <Button icon="md-add" type="primary" shape="circle" size="small"
                                            :disabled="pageRange!='SelectPage'"
                                            v-on:click="setEndPage('add')"></Button>
                                    <Input v-model="endPage" readonly :disabled="pageRange!='SelectPage'"
                                           style="width: 40px; margin-right: 10px;margin-left:10px;"/>
                                    <Button icon="md-remove" type="primary" shape="circle" size="small"
                                            :disabled="pageRange!='SelectPage'"
                                            v-on:click="setEndPage('remove')"></Button>
                                </div>
                            </Cell>
                            <Cell title="奇偶页面" label="Page Parity">
                                <RadioGroup v-model="pageParity" type="button" slot="extra">
                                    <Radio label="None">全部页面</Radio>
                                    <Radio label="OddPage">仅奇数页</Radio>
                                    <Radio label="EvenPage">仅偶数页</Radio>
                                </RadioGroup>
                            </Cell>
                        </CellGroup>
                    </Card>

                    <Card title="高级 - 打印选项" icon="ios-options" :padding="0" shadow
                          style="width: 90%; margin: 10px">
                        <CellGroup style="margin-top: 10px;margin-bottom: 10px;">
                            <Cell title="一张多页" label="Multi Page">
                                <Switch v-model="multiPage" size="large" slot="extra"
                                        @on-change="multiPageChange()">
                                    <span slot="open">ON</span>
                                    <span slot="close">OFF</span>
                                </Switch>
                            </Cell>
                            <Cell title="页面张数" label="Page Count" :disabled="!multiPage">
                                <RadioGroup v-model="multiPageCount" type="button" slot="extra"
                                            @on-change="setPageCount()">
                                    <Radio label="2" :disabled="!multiPage">2</Radio>
                                    <Radio label="4" :disabled="!multiPage">4</Radio>
                                    <Radio label="6" :disabled="!multiPage">6</Radio>
                                    <Radio label="9" :disabled="!multiPage">9</Radio>
                                    <Radio label="16" :disabled="!multiPage">16</Radio>
                                    <Radio label="Custom" :disabled="!multiPage">自定义</Radio>
                                </RadioGroup>
                            </Cell>
                            <Cell title="自定义页面张数" label="Custom Page Count" :disabled="!multiPage">
                                <div class="number-modifier" slot="extra">
                                    <Button icon="md-add" type="primary" shape="circle" size="small"
                                            v-on:click="setRow('add')"
                                            :disabled="multiPageCount!='Custom'||!multiPage"></Button>
                                    <Input v-model="multiPageRowNum" readonly slot="extra"
                                           :disabled="multiPageCount!='Custom'||!multiPage"
                                           style="width: 40px; margin-right: 10px;margin-left:10px;"/>
                                    <Button icon="md-remove" type="primary" shape="circle" size="small"
                                            v-on:click="setRow('remove')"
                                            :disabled="multiPageCount!='Custom'||!multiPage"></Button>
                                    <span style="margin-left:5px;margin-right:5px;"> 行 </span>
                                    <Button icon="md-add" type="primary" shape="circle" size="small"
                                            v-on:click="setCol('add')"
                                            :disabled="multiPageCount!='Custom'||!multiPage"></Button>
                                    <Input v-model="multiPageColNum" readonly
                                           :disabled="multiPageCount!='Custom'||!multiPage"
                                           style="width: 40px; margin-right: 10px;margin-left:10px;"/>
                                    <Button icon="md-remove" type="primary" shape="circle" size="small"
                                            v-on:click="setCol('remove')"
                                            :disabled="multiPageCount!='Custom'||!multiPage"></Button>
                                    <span style="margin-left:5px;margin-right:5px;"> 列 </span>
                                </div>
                            </Cell>
                            <Cell title="页面顺序" label="Page Order" style="height: 60px" :disabled="!multiPage">
                                <RadioGroup v-model="multiPageOrder" type="button" slot="extra"
                                            @on-change="multiPagePreviewRefresh=true">
                                    <Radio style="height: 50px;padding: 5px;text-align: center;" label="Z"
                                           :disabled="!multiPage"><img src="../images/Z.png" height="40"/></Radio>
                                    <Radio style="height: 50px;padding: 5px;text-align: center;" label="anti_Z"
                                           :disabled="!multiPage"><img src="../images/Anti-Z.png" height="40"/>
                                    </Radio>
                                    <Radio style="height: 50px;padding: 5px;text-align: center;" label="N"
                                           :disabled="!multiPage"><img src="../images/N.png" height="40"/></Radio>
                                    <Radio style="height: 50px;padding: 5px;text-align: center;" label="anti_N"
                                           :disabled="!multiPage"><img src="../images/Anti-N.png" height="40"/>
                                    </Radio>
                                </RadioGroup>
                            </Cell>
                            <Cell title="页面方向" label="Page Orientation" :disabled="!multiPage">
                                <RadioGroup v-model="multiPageOrientation" type="button" slot="extra"
                                            :disabled="!multiPage" @on-change="multiPagePreviewRefresh=true;">
                                    <Radio label="transverse" :disabled="!multiPage"
                                           v-on:click.native="turningMode='TUMBLE'">横向
                                    </Radio>
                                    <Radio label="lengthwise" :disabled="!multiPage"
                                           v-on:click.native="turningMode='DUPLEX'">纵向
                                    </Radio>
                                </RadioGroup>
                            </Cell>
                            <Cell title="双面打印" label="Duplex">
                                <Switch v-model="duplex" size="large" slot="extra">
                                    <span slot="open">ON</span>
                                    <span slot="close">OFF</span>
                                </Switch>
                            </Cell>
                            <Cell title="翻页方式" label="TurningMode">
                                <RadioGroup v-model="turningMode" type="button" slot="extra">
                                    <Radio label="DUPLEX" :disabled="!duplex">双面长边翻页</Radio>
                                    <Radio label="TUMBLE" :disabled="!duplex">双面短边翻页</Radio>
                                </RadioGroup>
                            </Cell>
                        </CellGroup>
                    </Card>
                </Col>
            </Row>
        </template>
    </v-coreLayout>
</template>
<script>
    import * as axios from "axios";
    import ExceptionModel from '../components/ExceptionModel.vue';
    import CountdownButton from '../components/CountdownButton.vue';
    import CoreLayout from '../components/CoreLayout.vue';
    import PDF from 'pdfjs-dist'

    export default {
        components: {
            'v-exception': ExceptionModel,
            'v-countdownButton': CountdownButton,
            'v-coreLayout': CoreLayout,
        },
        data() {
            return {
                /*
                * 临时数据
                */
                /*当前文档状态包含的页数（一张多页时会导致当前页数比固定页数少）*/
                filePageSize: 0,
                /*用户预览的当前页*/
                nowPage: 1,
                /*加载状态*/
                loading: false,
                multiPagePreviewRefresh: false,
                multiPagePreviewRefreshLoading: false,
                /*原始文件类型*/
                fileType: "",
                /*
                * 打印配置数据
                */
                /*文档打印起始页*/
                startPage: 1,
                /*文档打印终结页*/
                endPage: 0,
                /*文档打印份数（1-N）*/
                copies: 1,
                /*文档打印范围（AllPage‘全部打印’、CurrentPage‘当前页面’、SelectPage‘选定页面’）*/
                pageRange: "AllPage",
                /*双面打印（T/F)*/
                duplex: true,
                /*双面打印翻页方式（DUPLEX‘双面长边’、TUMBLE‘双面短边’）*/
                turningMode: "DUPLEX",
                /*页面奇偶性（NONE‘默认，全部打印’、OddPage‘仅奇数页’、EvenPage‘仅偶数页’）*/
                pageParity: "None",
                /*逐份打印（T/F）*/
                collate: false,
                /*一张多页拼合打印（T/F）*/
                multiPage: false,
                /*一张多页打印 行*/
                multiPageRowNum: 2,
                /*一张多页打印 列*/
                multiPageColNum: 1,
                /*一张多页打印 页面前进顺序（Z,anti_Z,N,anti_N）*/
                multiPageOrder: "Z",
                /*一张多页打印 方向（transverse‘横向’,lengthwise‘纵向’）*/
                multiPageOrientation: "lengthwise",
                /*一张多页打印 行列模式（2‘二行一列’,4‘二行二列’,6‘二行三列’,9‘三行三列’,16‘四行四列’,Custom‘自定义’）*/
                multiPageCount: "2",
                autoAdjustmentFlag: "",

                pdfDoc: null,
                reloadPreviewPdf:true,
            }
        },
        mounted() {
            this.selectPage(1);
        },
        methods: {
            multiPageChange() {
                this.reloadPreviewPdf=!this.reloadPreviewPdf;
                this.multiPagePreviewRefresh = this.multiPage;
                if (!this.multiPage) {
                    this.selectPage(1);
                }
            },
            selectPage(page) {
                this.nowPage=page;
                if(this.reloadPreviewPdf) {
                    if (this.multiPage) {
                        this.loadFile("http://localhost:8999/getPreviewFile?printUserMark=" + this.$root.printUserMark + "&type=final")
                    } else {
                        this.loadFile("http://localhost:8999/getPreviewFile?printUserMark=" + this.$root.printUserMark + "&type=original")
                    }
                    this.reloadPreviewPdf=false;
                }else{
                    this.renderPage(page)
                }
            },
            setAutoAdjustment() {
                if (this.multiPage == false) {
                    axios({
                        method: 'get',
                        url: 'http://localhost:8999/documentTypePrediction',
                        params: {
                            printUserMark: this.$root.printUserMark,
                        }
                    }).then((response) => {
                        let responseData = response.data;
                        if (responseData.state == "SUCCESS") {
                            this.fileType = responseData.msg;
                            switch (this.fileType) {
                                case "Unknow_Transverse":
                                    this.autoAdjustmentFlag = "FIX_T_Model";
                                    this.autoAdjustmentConfirm("UNKNOWN");
                                    break;
                                case "Unknow_Lengthwise":
                                    this.autoAdjustmentFlag = "FIX_L_Model";
                                    this.autoAdjustmentConfirm("UNKNOWN");
                                    break;
                                case "A4_lengthwise":
                                    this.autoAdjustmentFlag = "FIX_L_Model";
                                    this.autoAdjustmentConfirm("A4_L");
                                    break;
                                case "A4_transverse":
                                    this.sendParam();
                                    break;
                                case "PPT":
                                    this.autoAdjustmentFlag = "FIX_T_Model";
                                    this.autoAdjustmentConfirm("PPT");
                                    break;
                            }
                        } else {
                            this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, responseData.msg, responseData.code, responseData.state);
                        }
                    }).catch((reason) => {
                        this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, reason.toString());
                    });
                } else {
                    this.sendParam();
                }
            },
            autoAdjustmentConfirm(type) {
                let title, content;
                switch (type) {
                    case "PPT":
                        title = '<p style=\"font-size: 20px;\">检测到4/3或16/9的PowerPoint文件</p>';
                        content = '<p style=\"font-size: 16px;\">为了您的最佳打印体验，PowerPoint在打印时需根据纸张尺寸对页面进行智能缩放。</p>' +
                            '<br/><p style=\"font-size: 16px;\">我们强烈建议您进行自动调整，<span style="color:#f60;">拒绝智能缩放可能导致页面印刷不全、位置偏移等意外情况</span>，请您悉知！</p>';
                        break;
                    case "A4_L":
                        title = '<p style=\"font-size: 20px;\">检测到A4大小文件</p>';
                        content = '<p style=\"font-size: 16px;\">为了您的最佳打印体验，我们推荐对文档尺寸进行智能缩放。</p>' +
                            '<br/><p style=\"font-size: 16px;\">若您<span style="color:#f60;">拒绝</span>进行智能缩放，<span style="color:#f60;">在使用免费打印模式时可能会出现文档内容被覆盖等情况</span>，请您悉知！</p>';
                        break;
                    default:
                        title = '<p style=\"font-size: 20px;\">未能检测到纸张适应类型</p>';
                        content = '<p style=\"font-size: 16px;\">您的文件可能不能在本设备上正确印刷</p>' +
                            '<br/><p style=\"font-size: 16px;\">为了您的最佳打印体验，墨拓希望对文档尺寸进行智能缩放以进行打印尝试</p>' +
                            '<br/><p style=\"font-size: 16px;\">若您<span style="color:#f60;">拒绝</span>进行智能缩放，<span style="color:#f60;">可能导致页面印刷不全、位置偏移等意外情况</span>，请您悉知！</p>';
                        break;
                }
                this.$Modal.confirm({
                    title: title,
                    content: content,
                    loading: true,
                    okText: '没问题，请自动调整',
                    cancelText: '不，不要自动调整文档',
                    width:700,
                    onOk: () => {
                        this.autoAdjustment();
                    },
                    onCancel: () => {
                        this.sendParam();
                        this.$Modal.remove();
                    }
                });
            },
            autoAdjustment() {
                this.multiPagePreviewRefresh = true;
                this.multiPage = true;
                this.multiPageRowNum = 1;
                this.multiPageColNum = 1;
                this.multiPageOrder = "Z";
                this.multiPageOrientation = (this.autoAdjustmentFlag === "FIX_L_Model") ? "lengthwise" : "transverse";
                this.turningMode = (this.autoAdjustmentFlag === "FIX_L_Model") ? "DUPLEX" : "TUMBLE";
                this.multiPageCount = "Custom";
                if (!this.loading) {
                    axios({
                        method: 'get',
                        url: 'http://localhost:8999/splicedPage',
                        params: {
                            printUserMark: this.$root.printUserMark,
                            multiPageColNum: this.multiPageColNum,
                            multiPageRowNum: this.multiPageRowNum,
                            multiPageOrientation: this.multiPageOrientation,
                            multiPageOrder: this.multiPageOrder,
                        }
                    }).then((response) => {
                        let responseData = response.data;
                        if (responseData.state == "SUCCESS") {
                            this.multiPagePreviewRefresh = false;
                            this.sendParam();
                            this.$Modal.remove();
                        } else {
                            this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, responseData.msg, responseData.code, responseData.state);
                        }
                    }).catch((reason) => {
                        this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, reason.toString());
                    });
                } else {
                    this.$Modal.remove();
                    this.$Notice.warning({
                        title: '注意', desc: '在页面全部加载完毕前，不能自动调整页面，请等待加载完毕后重试'
                    });
                }
            },
            sendParam() {
                if (!this.multiPagePreviewRefresh && !this.multiPagePreviewRefreshLoading) {
                    axios({
                        method: 'post',
                        url: 'http://localhost:8999/setPrintingParam',
                        data: {
                            printUserMark: this.$root.printUserMark,

                            pageRange: this.pageRange,
                            startPage: this.startPage,
                            endPage: this.endPage,
                            pageParity: this.pageParity,

                            copies: this.copies,
                            collate: this.collate,

                            multiPage: this.multiPage,
                            multiPageRowNum: this.multiPageRowNum,
                            multiPageColNum: this.multiPageColNum,
                            multiPageOrder: this.multiPageOrder,
                            multiPageOrientation: this.multiPageOrientation,
                            multiPageCount: this.multiPageCount,

                            duplex: this.duplex,
                            turningMode: this.turningMode,
                        }
                    }).then((response) => {
                        let responseData = response.data;
                        if (responseData.state == "SUCCESS") {
                            clearInterval(this.countdownClock);
                            this.$router.push({
                                name: 'ChooseServiceType',
                                params: {
                                    direction: this.multiPageOrientation,
                                }
                            });
                        } else {
                            this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, responseData.msg, responseData.code, responseData.state);
                        }
                    }).catch((reason) => {
                        this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, reason.toString());
                    });
                } else {
                    this.$Notice.warning({
                        title: '注意', desc: '在一张多页预览加载完毕前，不能提交打印任务，请等待加载完毕后重试'
                    });
                }
            },
            setPageCount() {
                this.multiPagePreviewRefresh = true;
                switch (this.multiPageCount) {
                    case "2":
                        this.multiPageColNum = 1;
                        this.multiPageRowNum = 2;
                        break;
                    case "4":
                        this.multiPageColNum = 2;
                        this.multiPageRowNum = 2;
                        break;
                    case "6":
                        this.multiPageColNum = 3;
                        this.multiPageRowNum = 2;
                        break;
                    case "9":
                        this.multiPageColNum = 3;
                        this.multiPageRowNum = 3;
                        break;
                    case "16":
                        this.multiPageColNum = 4;
                        this.multiPageRowNum = 4;
                        break;
                    case "Custom":
                        this.multiPageColNum = 2;
                        this.multiPageRowNum = 2;
                        break;
                }
            },
            loadFile (url) {
                PDF.getDocument(url)
                    .then((pdf) => {
                        this.pdfDoc = pdf;
                        this.filePageSize= this.pdfDoc.numPages;
                        this.$nextTick(() => {
                            this.renderPage(1)
                        })
                    })
            },

            renderPage (num) {
                this.pdfDoc.getPage(num)
                    .then((page) => {
                        let canvas = document.getElementById('canvas');
                        let ctx = canvas.getContext('2d');

                        ctx.clearRect( 0, 0, ctx.width, ctx.height );  //清除画布

                        let bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1 // 浏览器在渲染canvas之前会用几个像素来来存储画布信息,类似img
                        let ratio = 1 / bsr;

                        let viewport = (this.multiPageOrientation==="transverse")?page.getViewport(1, 270):page.getViewport(1);

                        canvas.width = viewport.width * ratio;
                        canvas.height = viewport.height * ratio;
                        canvas.style.height = "350px";
                        let renderContext = {
                            canvasContext: ctx,
                            viewport: viewport
                        };
                        page.render(renderContext)
                    })
            },
            splicingPage() {
                if (!this.loading) {
                    this.multiPagePreviewRefresh = false;
                    this.multiPagePreviewRefreshLoading = true;
                    axios({
                        method: 'get',
                        url: 'http://localhost:8999/splicedPage',
                        params: {
                            printUserMark: this.$root.printUserMark,
                            multiPageColNum: this.multiPageColNum,
                            multiPageRowNum: this.multiPageRowNum,
                            multiPageOrientation: this.multiPageOrientation,
                            multiPageOrder: this.multiPageOrder,
                        }
                    }).then((response) => {
                        let responseData = response.data;
                        if (responseData.state == "SUCCESS") {
                            this.filePageSize = parseInt(responseData.msg);
                            this.endPage = parseInt(responseData.msg);

                            this.reloadPreviewPdf=true;
                            this.multiPagePreviewRefreshLoading = false;
                            this.selectPage(1);
                        } else {
                            this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, responseData.msg, responseData.code, responseData.state);
                        }
                    }).catch((reason) => {
                        this.$refs.exceptionModel.openExceptionModel(this.$root.printUserMark, reason.toString());
                    });
                } else {
                    this.$Notice.warning({
                        title: '注意', desc: '在页面全部加载完毕前，一张多页无法预览'
                    });
                }

            },
            setCopies(action) {
                switch (action) {
                    case "add":
                        if ((this.duplex && this.copies * this.filePageSize > 100)
                            || (!this.duplex && this.copies * this.filePageSize > 50)) {
                            this.$Notice.warning({
                                title: '注意', desc: '单次打印的总页数不能超过50页哦，超大文件若需多份请分开打印哦'
                            });
                        } else {
                            this.copies = this.copies + 1;
                        }
                        break;
                    case "remove":
                        if (this.copies > 1) {
                            this.copies = this.copies - 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '至少需要印刷一份呢亲亲~'
                            });
                        }
                }
            },
            setStartPage(action) {
                switch (action) {
                    case "add":
                        if (this.startPage < this.endPage) {
                            this.startPage = this.startPage + 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '起始页不得在终结页之后呢！'
                            });
                        }
                        break;
                    case "remove":
                        if (this.startPage > 1) {
                            this.startPage = this.startPage - 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '已经到达首页了呢'
                            });
                        }
                        break;
                }
            },
            setEndPage(action) {
                switch (action) {
                    case "add":
                        if (this.endPage < this.filePageSize) {
                            this.endPage = this.endPage + 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '已经到达末尾了呢'
                            });
                        }
                        break;
                    case "remove":
                        if (this.endPage > this.startPage) {
                            this.endPage = this.endPage - 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '终结页不得在起始页之后呢！'
                            });
                        }
                        break;
                }
            },
            setRow(action) {
                switch (action) {
                    case "add":
                        if (this.multiPageRowNum <= 16) {
                            this.multiPageRowNum = this.multiPageRowNum + 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '最多不建议超过16行呢'
                            });
                        }
                        break;
                    case "remove":
                        if (this.multiPageRowNum > 1) {
                            this.multiPageRowNum = this.multiPageRowNum - 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '最低不能小于1行呢'
                            });
                        }
                        break;
                }
                this.multiPagePreviewRefresh = true;
            },
            setCol(action) {
                switch (action) {
                    case "add":
                        if (this.multiPageColNum <= 16) {
                            this.multiPageColNum = this.multiPageColNum + 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '最多不建议超过16行呢'
                            });
                        }
                        break;
                    case "remove":
                        if (this.multiPageColNum > 1) {
                            this.multiPageColNum = this.multiPageColNum - 1;
                        } else {
                            this.$Notice.warning({
                                title: '注意', desc: '最低不能小于1行呢'
                            });
                        }
                        break;
                }
                this.multiPagePreviewRefresh = true;
            },
        },
    }
</script>